package FilesDelete;

import java.io.File;
import java.io.IOException;

/**
 * @Program: copy-and-code-convert
 * @Description: 同一个文件夹会删除所有的文件
 * @Author: zqs
 * @Create： 2021-06-28-18:18
 */
public class DelChongFu2 {
    public void del(String folder1, String folder2) throws IOException {
        if (folder1 == null || folder2 == null) {
            return;
        }
        if (folder1 == "" || folder2 == "") {
            return;
        }

        File[] files_1 = new File(folder1).listFiles();
        File[] files_2 = new File(folder2).listFiles();

        for (File file : files_1) {
            for (File file2 : files_2) {
                if (file.getName() == file2.getName() || file.length()==file2.length()){
                    System.out.println(file2.getName());
                    String temp = file2.getPath();
                    if (file2.delete()) {
                        System.out.println(temp + "\t\t<---已经被删除");
                    }
                }
            }
        }
    }

}

